package com.crm.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.crm.model.SysRight;
import com.crm.model.SysUser;
import com.crm.service.IRightService;
import com.crm.util.Courier;

/**
 * controller层接受请求，进行分页，DTO对象封装操作
* @ClassName: RightController 
* @Description: TODO 
* @author 一神
* @date 2017年5月24日 下午2:27:51
 */
@Controller
@RequestMapping
public class RightController {
	@Autowired
	private IRightService rightService;
	
	
	
	//参数工具类
	@Autowired
	private Courier courier;
	
	/**
	 * 登陆成功后显示权限页面
	* @return String
	* @param request
	* @param session
	* @return
	 */
	@RequestMapping(value="/index",method=RequestMethod.GET)
	public String index(HttpServletRequest request,HttpSession session){
		
		SysUser sysUser = (SysUser)session.getAttribute("sysUser");
		
		//获取角色等级
		int usrRoleId = sysUser.getUsrRoleId();
		
		//所有权限都拥有权限1 即父id为null
		List<SysRight> list = rightService.showRight(usrRoleId,null);
		request.setAttribute("rightList", list);	
		return "index";
	}
	

	
	/**
	 * 因为页面所要传的值是x.jsp字符串，无法进后台
	* @return Courier
	* @param page
	* @param request
	* @return
	 */
	/*@RequestMapping(value="/skip/{page}",method=RequestMethod.GET)
	public Courier skip(@PathVariable String page,HttpServletRequest request){
		//路径拼接
		courier.setPage("img/"+page);
		request.setAttribute("courier", courier);
		return courier;
	}*/
	
	
	
	
	
	
}
